Skip to content

fix Pyrefly infers Iterator[Any] instead of Iterator[int] for iter([0]) #3265 - #4227

Open
asukaminato0721 wants to merge 1 commit into
facebook:mainfrom
asukaminato0721:3265
Open

fix Pyrefly infers Iterator[Any] instead of Iterator[int] for iter([0]) #3265#4227
asukaminato0721 wants to merge 1 commit into
facebook:mainfrom
asukaminato0721:3265

Conversation

@asukaminato0721

@asukaminato0721 asukaminato0721 commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #3265

Prevented bounded generic Any from incorrectly contextually typing list literals.

Test Plan

add test

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot added the stale label Aug 7, 2026
@meta-codesync

meta-codesync Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D115174318. (Because this pull request was imported automatically, there will not be any future comments.)

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Diff from mypy_primer, showing the effect of this PR on open source code:

cloud-init (https://github.com/canonical/cloud-init)
+ ERROR tests/unittests/config/test_cc_ssh.py:279:17-19: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]

cki-lib (https://gitlab.com/cki-project/cki-lib)
- ERROR cki_lib/metrics/server.py:23:12-24: Returned type `Iterator[Any]` is not assignable to declared return type `None` [bad-return]
+ ERROR cki_lib/metrics/server.py:23:12-24: Returned type `Iterator[Unknown]` is not assignable to declared return type `None` [bad-return]

setuptools (https://github.com/pypa/setuptools)
- ERROR setuptools/_distutils/tests/test_extension.py:91:33-57: Argument `Iterator[Any]` is not assignable to parameter `sources` with type `list[str]` in function `distutils.extension.Extension.__init__` [bad-argument-type]
+ ERROR setuptools/_distutils/tests/test_extension.py:91:33-57: Argument `Iterator[str]` is not assignable to parameter `sources` with type `list[str]` in function `distutils.extension.Extension.__init__` [bad-argument-type]

ibis (https://github.com/ibis-project/ibis)
+ ERROR ibis/backends/clickhouse/tests/test_operators.py:259:28-30: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]

pandas (https://github.com/pandas-dev/pandas)
- ERROR pandas/tests/indexes/multi/test_constructors.py:564:38-59: Argument `Iterator[Any]` is not assignable to parameter `iterables` with type `Sequence[Iterable[Hashable]]` in function `pandas.core.indexes.multi.MultiIndex.from_product` [bad-argument-type]
+ ERROR pandas/tests/indexes/multi/test_constructors.py:564:38-59: Argument `Iterator[list[str]]` is not assignable to parameter `iterables` with type `Sequence[Iterable[Hashable]]` in function `pandas.core.indexes.multi.MultiIndex.from_product` [bad-argument-type]

spack (https://github.com/spack/spack)
+ ERROR lib/spack/spack/package_base.py:1263:40-42: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]

schema_salad (https://github.com/common-workflow-language/schema_salad)
+ ERROR src/schema_salad/dlang_codegen.py:148:55-57: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
- ERROR src/schema_salad/dlang_codegen.py:150:16-25: Implicit conversion of `str | Any` to `bool` is not allowed [implicit-bool]
+ ERROR src/schema_salad/dlang_codegen.py:150:16-25: Implicit conversion of `str | Unknown` to `bool` is not allowed [implicit-bool]

@github-actions github-actions Bot removed the stale label Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pyrefly infers Iterator[Any] instead of Iterator[int] for iter([0])

2 participants